import { fileURLToPath, URL } from 'node:url';

import { defineConfig, mergeConfig } from 'vite';
import qiankun from 'vite-plugin-qiankun';

import baseConfig from '../../core/vite.config.base';

const currentConfig = defineConfig({
  root: fileURLToPath(new URL('./', import.meta.url)),
  base: process.env.NODE_ENV === 'development' ? '/' : '/subApps/userManagement/',
  server: {
    port: 7099,
    origin: 'http://localhost:7099',
  },
  plugins: [
    qiankun('userManagement', { useDevMode: true }),
  ],
  resolve: {
    alias: {
      '@userManagement': fileURLToPath(new URL('./src', import.meta.url)),
    },
  },
});

export default mergeConfig(baseConfig, currentConfig);
